package com.woniuxy.mapper;

import java.util.List;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.woniuxy.entity.Category;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.woniuxy.entity.Category;

@Mapper
public interface CategoryMapper {

	//查询所有物料
	@Select("select * from t_category1")
	public List<Category> findAllCategory();
	
	//查询所有入库
	@Select("select cgname from t_category")
	public List<Category> findCategoryOfCgname();
		
	//新增一条物料
	@Insert("insert into t_category1(cgid,cgname,status,cgsort,cgtime,cgdescription) values(default,#{cgname},#{status},#{cgsort},#{cgtime},#{cgdescription})")
	public int addCategory(Category category);
	
	//根据状态查询物料
	@Select("select * from t_category1 where status=#{status}")
	public List<Category> findCategoryByStatus(int status);
		
	//模糊查询
	@Select("select * from t_category1 where cgname like CONCAT('%',#{cgname},'%')")
	public List<Category> findCategoryByCgname(String cgname);
		
	//删除操作
	@Delete("delete from t_category1 where cgid=#{cgid}")
	public int delectCategoryByCgid(int cgid);
			
	//改switch状态
	@Update("update t_category1 set status=#{status} where cgid=#{cgid}")
	public int updateSwitch(Category category);
		
}
